import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    private double xOffset = 0;
    private double yOffset = 0;

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.initStyle(StageStyle.UNDECORATED); // 设置为无边框
        primaryStage.setTitle("WeMeet");
        primaryStage.getIcons().add(new Image("res/icon_about_selected@3x.png"));
        //Pane root= FXMLLoader.load(getClass().getResource("/ui/homePage.fxml"));
        Pane root = FXMLLoader.load(getClass().getResource("/ui/Login.fxml"));
        Scene scene = new Scene(root);
        primaryStage.setScene(scene);
        // 设置拖动窗口的事件处理
        root.setOnMousePressed(event -> {
            xOffset = event.getSceneX();
            yOffset = event.getSceneY();
        });
        //监听了鼠标按下和拖动事件，通过计算偏移量来更新窗口的位置
        root.setOnMouseDragged(event -> {
            primaryStage.setX(event.getScreenX() - xOffset);
            primaryStage.setY(event.getScreenY() - yOffset);
        });
        primaryStage.show();
    }
}